package org.ns.learn.db.autoconf;

import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import org.springframework.beans.factory.FactoryBean;

import javax.sql.DataSource;

public class DBSourceConfig implements FactoryBean<DataSource> {

    private DBSourceWrapper dataSource;
    private boolean start;

    public DBSourceConfig(DBSourceWrapper dataSource) {

        this.dataSource = dataSource;
    }

    @Override
    public DataSource getObject() throws Exception {
        if (!start) {
            dataSource.restart();
        }
        return dataSource;
    }

    @Override
    public Class<?> getObjectType() {
        return DBSourceWrapper.class;
    }
//    HikariConfig


}
